﻿using System.Security.Principal;
using BLL.Installer;
using BLL.Interface.Base;

namespace BLL.Model.Base
{
    public class UserIdentity : IIdentity
    {
        public LoginUserInfo UserInfo { get; private set; }

        public UserIdentity(LoginUserInfo user)
        {
            UserInfo = user;
        }

        public string Name
        {
            get { return UserInfo.UserAccountName; }
        }

        public string AuthenticationType
        {
            get { return "default"; }
        }

        public bool IsAuthenticated
        {
            get
            {
                if (string.IsNullOrWhiteSpace(Name))
                {
                    return false;
                }
                ILoginHelper loginHelperManager = ContainerHelper.Instance.Container.Resolve<ILoginHelper>();
                return loginHelperManager.CheckUserIsLogin(Name);
            }
        }

    }
}